<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML" 4.01"//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- Created: September 26, 2001-->
<!--
$Id: ContactAdd.php,v 1.4 2002/02/12 19:23:22 eugenem Exp $
$Header: /export/home/eugenem/public_html/ComplianceReports/RCS/ContactAdd.php,v 1.4 2002/02/12 19:23:22 eugenem Exp $
$Log: ContactAdd.php,v $
Revision 1.4  2002/02/12 19:23:22  eugenem
Enclose $Phone and $Pager in quotes in INSERT query.

Revision 1.3  2001/11/02 19:04:44  eugenem
Moved HTTP_*_VARS processing to dbc.inc

Revision 1.2  2001/11/02 14:56:47  eugenem
Moved database connect statements to a separate file.

Revision 1.1  2001/09/27 17:35:29  eugenem
Initial revision

-->

<html>
<head>
<title>Radiology Equipment Database</title>
<meta name="author" content="Eugene Mah">
<link rev="made" href="mailto:eugenem@ix.netcom.com">
<link rev="home" href="http://home.netcom.com/~eugenem/">
<meta name="description" content="">
<meta name="Keywords" content="">
<meta name="Reply-to" content="eugenem@ix.netcom.com">
<META http-equiv="PICS-Label" content='(PICS-1.1 "http://www.classify.org/safesurf/" l r (SS~~0001))'>
<?PHP
require('functions.inc');
require('dbc.inc');

?>
</head>

<body>
<h1>Radiology Equipment Database</h1>
<?PHP
$loc = mysql_query("select * from Location");

if (isset($FName) && isset($LName)) {
  /*
    First check the database to see if this person is already in there
  */
  $name = $FName . " " . $LName;
  $query = "select * from ContactPeople where Name=\"$name\"";
  $result = mysql_query($query)
    or die ("Query failed: $query<br>");

  if (mysql_num_rows($result)) {  // Check if this contact exists already
    //Person already exists
    echo "<h2>Contact not added</h2>\n";
    echo "<p>$name already exists in the database</p>\n";
  } else {  // Go ahead and insert this contact
    $query = "insert into ContactPeople (Name,Phone,Pager,Email,LocationID,Title) values ";
    $query .= "(\"$name\",\"$Phone\",\"$Pager\",\"$Email\",$LocID,\"$Title\")";

    $result = mysql_query($query)
      or die ("<p>Insert failed: $query</p>");

    echo "<h2>Contact Added</h2>\n";
    echo "<p>$name has been added to the Contacts database</p>\n";
  }
}
?>

<h2>Add Contact Person</h2>
<form action="ContactAdd.php" method="POST">
<p>First Name: <input type="TEXT" name="FName" size="15">&nbsp;
Last Name: <input type="TEXT" name="LName" size="15"></p>
<p>Title: <input type="TEXT" name="Title" size="20"></p>
<p>Phone: <input type="TEXT" name="Phone" size="10">&nbsp;
Pager: <input type="TEXT" name="Pager" size="10"></p>
<p>Email: <input type="TEXT" name="Email" size="25"></p>
<p>Location: <?PHP echo listbox_field($loc,"LocID",0); ?></p>
<p><input type="SUBMIT" value="Add"> / <input type="RESET" value="Reset"> / <a href="index.html" target="_top" >Main</a></p>
</form>

<?PHP mysql_close(); ?>

</body>
</html>
